<template>
  <div id="ArticleForm">
    <el-table :data="list" style="width: 100%">
      <el-table-column prop="name" label="名称" width="346"> </el-table-column>
      <el-table-column label="类型" width="215">
        <template slot-scope="scope">
          <span v-if="scope.row.type == 3">文章类型</span>
        </template>
      </el-table-column>
      <el-table-column prop="extra" label="分类图标" width="114">
        <template slot-scope="scope">
          <div class="image">
            <img :src="scope.row.extra" alt="" />
          </div>
        </template>
      </el-table-column>
      <el-table-column prop="sort" label="排序" width="215"> </el-table-column>
      <el-table-column label="状态" width="215">
        <template slot-scope="scope">
          <el-switch v-model="scope.row.status"> </el-switch>
        </template>
      </el-table-column>
      <el-table-column fixed="right" label="操作" width="300">
        <template slot-scope="scope">
          <el-button @click="handleClick(scope.row)" type="text" size="small"
            >编辑</el-button
          >
          <el-button
            type="text"
            size="small"
            @click.native="setdel(scope.row.id)"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { delTitle } from "@/network/api/classifManager/index";
export default {
  name: "ArticleForm",
  props: {
    list: {
      type: Array,
      default: function () {
        return [];
      },
    },
  },
  methods: {
    handleClick(row) {
      console.log(row);
    },
    //删除
    setdel(id) {
      this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(async () => {
          this.$message({
            type: "success",
            message: "删除成功!",
          });
          let res = await delTitle(id);
          console.log(res.data.code);
          this.$mitt.emit("deled", res.data.code);
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
  },

  data() {
    return {};
  },
};
</script>

<style scoped>
.image img {
  width: 30px;
  height: 30px;
}
</style>